package com.kexin.coupon.config;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

/**
 * 卡券平台配置参数
 * @author ao
 */
@Configuration
public class CouponConfig {

	/** 接口请求前路径 **/
	@Value("${coupon.baseUrl}")
	private String baseUrl;

	/** 外部渠道ID **/
	@Value("${coupon.appId}")
	private String appId;

	/** 版本号 **/
	@Value("${coupon.version}")
	private String version;

	/** 获取token的clientId **/
	@Value("${coupon.clientId}")
	private String clientId;

	/** 获取token验签 **/
	@Value("${coupon.clientSecret}")
	private String clientSecret;

	/** 平台grantType **/
	@Value("${coupon.grantType}")
	private String grantType;

	/** 异步通知key **/
	@Value("${coupon.appKey}")
	private String appKey;

	/** 异步通知验签 **/
	@Value("${coupon.appSecret}")
	private String appSecret;

	/** 获取token接口URL（不含接口请求前路径，代码里自动加上接口请求前路径） **/
	@Value("${coupon.getAuthorizationUrl}")
	private String getAuthorizationUrl;

	/** 查询卡券列表接口URL **/
	@Value("${coupon.queryCouponListUrl}")
	private String queryCouponListUrl;

	/** 卡券申领接口URL **/
	@Value("${coupon.busiApply}")
	private String busiApply;

	/** 卡券退货接口URL **/
	@Value("${coupon.busiRefund}")
	private String busiRefund;

	/** 卡券核销通知URL **/
	@Value("${coupon.busiUsedResultUrl}")
	private String busiUsedResultUrl;

	private static CouponConfig couponConfig;

	@PostConstruct
	public void init() {
		couponConfig = this;
		couponConfig.baseUrl = baseUrl;
		couponConfig.appId = appId;
		couponConfig.version = version;
		couponConfig.clientId = clientId;
		couponConfig.clientSecret = clientSecret;
		couponConfig.grantType = grantType;
		couponConfig.appKey = appKey;
		couponConfig.appSecret = appSecret;
		couponConfig.getAuthorizationUrl = getAuthorizationUrl;
		couponConfig.queryCouponListUrl = queryCouponListUrl;
		couponConfig.busiApply = busiApply;
		couponConfig.busiRefund = busiRefund;
		couponConfig.busiUsedResultUrl = busiUsedResultUrl;
	}

	public static String getBaseUrl() {
		return couponConfig.baseUrl;
	}

	public static String getAppId() {
		return couponConfig.appId;
	}

	public static String getVersion() {
		return couponConfig.version;
	}

	public static String getClientId() {
		return couponConfig.clientId;
	}

	public static String getClientSecret() {
		return couponConfig.clientSecret;
	}

	public static String getGrantType() {
		return couponConfig.grantType;
	}

	public static String getAppKey() {
		return couponConfig.appKey;
	}

	public static String getAppSecret() {
		return couponConfig.appSecret;
	}

	public static String getGetAuthorizationUrl() {
		return couponConfig.getAuthorizationUrl;
	}

	public static String getQueryCouponListUrl() {
		return couponConfig.queryCouponListUrl;
	}

	public static String getBusiApply() {
		return couponConfig.busiApply;
	}

	public static String getBusiRefund() {
		return couponConfig.busiRefund;
	}

	public static String getBusiUsedResultUrl() {
		return couponConfig.busiUsedResultUrl;
	}
}
